#ifndef GV_SETTING_H
#define GV_SETTING_H
#include <QString>
#include <QSettings>
#include <QtSql>
#define PASSWORDLENGTH 11
enum GVLANGUAGE{
    ENGLISH = 0,
    CHINESE=1,
    DUTCH=2,
    FRENCH=3,
    GERMAN=4,
    INVALIDLANGUAGE=5
};
class GV_Setting
{
public:
    void GV_SetPassword(int level, QString pwd);
    QString GV_GetPassword(int level);
    int GV_GetFunctionLevel(int function);
    void GV_SetFunctionLevel(int function, int level);
    QString GV_GetShowDialog();
    QString GV_GetFromDialog();
    QString GV_GetToDialog();
    void GV_SetShowDialog(QString name);
    void GV_SetFromDialog(QString name);
    void GV_SetToDialog(QString name);
    GV_Setting();

    //void GV_SetLanguage(QString name);
    QString GV_GetLanguage();
    QString GV_GetLanguageName();

    /*********database relationship***********/
    GV_Setting(QString type);
    bool AddUser(QString name, QString password, bool level1, bool level2, bool level3);
    bool DelUser(QString name);
    bool CheckUser(QString name, QString password);

    bool ModifyPassword(QString name, QString newpassword);
    bool ModifyPassword(QString name, QString oldpassword, QString newpassword);
    //QString GV_GetLanguage();
    bool GV_SetLanguage(QString lan);
    //QString GV_GetLanguageName();




    void show();

private:
    QString language;
    QString level1Password;
    QString level2Password;
    QString level3Password;
    QString screenlockPassword;
    QSettings *settings;
    QChar passwordArray[3][6];

    /*********database relationship***********/
    QSqlDatabase db;
    QSqlQuery *query;

    bool HasUser(QString name);
    bool HasUser(QString name, QString password);

    GVLANGUAGE GetLanguage();
    GVLANGUAGE GetLanguage(QString name);
    bool SetLanguage(GVLANGUAGE lan);
    bool SetLanguage(GVLANGUAGE lan, QString name);
};
#endif // GV_SETTING_H
